
import 'package:logmanager/utils/string_ext.dart';

import '../../bean/login_bean.dart';

class BeanFactory {
  static T? generateOBJ<T>(json) {
    try {
      if (T == List) {
        return [] as T;
      } else if (T == LoginBean) {
        return LoginBean.fromJson(json) as T;
      } /*else if (T == DoctorBean) {
        return DoctorBean.fromJson(json) as T;
      } else if (T == List<DepartmentListBean>) {
        /// 部门管理
        return departmentListBeanFromJson(json) as T;
      } else if (T == DoctorManageBean) {
        return DoctorManageBean.fromJson(json) as T;
      } else if (T == DepartmentUpdataBean) {
        return DepartmentUpdataBean.fromJson(json) as T;
      } else if (T == List<UserBean>) {
        return userListBeanFromJson(json) as T;
      } else if (T == List<ReputationBean>) {
        return ReputationBeanFromJson(json) as T;
      } else if (T == List<PostManagerListBean>) {
        ///岗位管理
        return posyManagerListBeanFromJson(json) as T;
      } else if (T == PostManagerCreatBean) {
        return PostManagerCreatBean.fromJson(json) as T;
      } else if (T == StaffManagerListBean) {
        return StaffManagerListBean.fromJson(json) as T;
      } else if (T == StaffInfoBean) {
        return StaffInfoBean.fromJson(json) as T;
      } else if (T == List<InquiryTypeBean>) {
        return inquiryTypeListBeanFromJson(json) as T;
      } else if (T == List<PurposeBean>) {
        return purposeBeanFromJson(json) as T;
      } else if (T == CallOnDetailsBean) {
        return CallOnDetailsBean.fromJson(json) as T;
      } else if (T == CallOnRecordListBean) {
        return CallOnRecordListBean.fromJson(json) as T;
      } else if (T == OrderListbean<ConsultOrderBean>) {
        return OrderListbean<ConsultOrderBean>.fromJson(json) as T;
      } else if (T == OrderListbean<RecipelOrderBean>) {
        return OrderListbean<RecipelOrderBean>.fromJson(json) as T;
      } else if (T == UserBean) {
        return UserBean.fromJson(json) as T;
      }else if (T == DoctorBindBean) {
        return DoctorBindBean.fromJson(json) as T;
      }else if (T == XlDoctorBean) {
        return XlDoctorBean.fromJson(json) as T;
      }else if (T == XlDoctorManageBean) {
        return XlDoctorManageBean.fromJson(json) as T;
      } else if (T == OrderFeeBean) {
        return OrderFeeBean.fromJson(json) as T;
      }*/ else {
        "解析失败请添加Bean类".toast();
        return null;
      }
    } catch (e) {
      "json解析失败${e.toString()}".loge();
      "json解析失败${e.toString()}".toast();
      return null;
    }
  }
}
